//author:kakake
class tsbasedictController {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn()
    }

    //获取分类
    getdataclass() {

        var strsql = "SELECT ClassId,Code,Name,Pym,Wbm,Szm,Memo,DelFlag,SortOrder FROM BaseDictClass";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql);
    }

    //获取内容（分页）
    getdatacontext() {
        var classid = TSLobsterAPI.Program.RequestQuery("classid", "1001");
        var keywords = TSLobsterAPI.Program.RequestQuery("keywords", "");

        var pageInfo = {
            key: "Id",
            page: TSLobsterAPI.Program.RequestQuery('page', 0),
            perPage: TSLobsterAPI.Program.RequestQuery('limit', 10),
            totalRecord: 0,
            totalPage: 0
        }

        var strsql = "SELECT Id,ClassId,Code,Name,Pym,Wbm,Szm,Memo,DelFlag,SortOrder,CityFlag FROM BaseDictContent \
        WHERE ClassId=@classid and (Code LIKE @keywords or Name LIKE @keywords)";

        var dbparams = {
            classid: classid,
            keywords: "%" + keywords + "%"
        }

        var list = TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, dbparams, pageInfo);

        return { list: list, count: pageInfo.totalRecord };
    }
}